<?php

namespace App\Http\Controllers\Api;

use App\Services\UserService;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Services\BaseImgService;
use App\Lib\Util\ResponseUtil;

class BaseImgController extends Controller
{
    private $baseImgService = null;

    public function __construct(BaseImgService $baseImgService)
    {
        $this->baseImgService = $baseImgService;
    }

    public function getImages(Request $request)
    {
        $input = $request->all();

        $result = $this->baseImgService->getBaseImages($input, false);

        //输入了城市id的情况下找不到任何图片，则去掉城市id直接查找默认的图片
        if (count($result) == 0 && !empty($input['cityId'])) {
            $input['cityId'] = 0;
            $result = $this->baseImgService->getBaseImages($input, false);
        }

        return ResponseUtil::jsonResponse(true, 0, '', $result);
    }
}
